// 使用Mock
const Mock = require('mockjs')
Mock.setup({
  timeout: '500-1000'
})

// 用户信息
const users = [
  {
    id:1,
    role:'经理',
    token:'经理-token',
    rights:[]
    
},
{
    id:2,
    role:'入库员',
    token:'入库员-token',
    rights:[]
},
{
    id:3,
    role:'入库核验员',
    token:'入库核验员-token',
    rights:[]
},
{
    id:4,
    role:'出库员',
    token:'出库员-token',
    rights:[]
},
{
    id:5,
    role:'出库核验员',
    token:'出库核验员-token',
    rights:[]
},
{
    id:6,
    role:'货物管理员',
    token:'货物管理员-token',
    rights:[]
},

{
    id:7,
    role:'环境管理员',
    token:'环境管理员-token',
    rights:[]
},
{
    id:8,
    role:'盘查员',
    token:'盘查员-token',
    rights:[]
},
{
    id:9,
    role:'技术管理员',
    token:'技术管理员-token',
    rights:[]
}
]

// 权限信息 将权限信息从用户信息中抽离出来 不同身份对应不同的路由信息
// 这样方便了后期的维护 否则以后每加一个页面就需要在每个用户信息中做更改 十分的不方便 如果用户多了更是增添了不必要的麻烦
// 将用户直接分为不同身份 然后对不同身份做处理 这样比较合理
const roles = {
    超级管理员:[
        {
            id:1,
            authName:'物流管理',
            children:[{
                id:11,
                authName:'入库员',
                path:'theFirstInput',
                rights:['view','edit','add','delete']
            },
        {
            id: 12,
                authName:'入库核验员',
                path:'outputCheck',
                rights:['view','edit','add','delete']
        },
      {
        id:13,
        authName:'出库员',
        path:'output',
        rights:['view','edit','add','delete']
      },
      {
        id:14,
        authName:'出库核验员',
        path:'outputCheck',
        rights:['view','edit','add','delete']
      }
      ]
        },
        {
            id:2,
            authName:'货物管理',
            children:[{
                id:21,
                authName:'查看',
                path:'check',
                rights:['view']
            },
        {
            id:22,
            authName:'处理',
            path:'handle2',
            rights:['view','edit','add','delete']
        }]
        },
        {
        id:3,
        authName:'仓库管理',
        children:[
            {
                id:31,
                authName:'仓库肉类',
                path:'meat',
                show: true,
                rights:['view','edit','add','delete']
            },
            {
                id:32,
                authName:'仓库果蔬类',
                path:'fruit',
                rights:['view','edit','add','delete']
            },
            {
                id:33,
                authName:'仓库加工类',
                path:'process',
                rights:['view','edit','add','delete']
            },
            {
                id:34,
                authName:'仓库蛋类',
                path:'egg',
                rights:['view','edit','add','delete']
            },
            {
                id:35,
                authName:'盘查记录',
                path:'chuli',
                rights:['view','edit','add','delete']
            }
        ]
        },
        {
            id:4,
            authName:'员工管理',
            children:[{
                id:41,
                authName:'处理',
                path:'handle2',
                rights:['view','edit','add','delete']
            },
            {
                id:42,
                authName:'查看',
                path:'check2',
                rights:['view','edit','add','delete']
            }
        ]
        },
       {
         id:5,
         authName:'技术管理',
         children:[
             {
                 id:51,
                 authName:'数据导出',
                 path:'backup',
                
                 rights:['view','edit','add','delete']
             },
             {
                 id:52,
                 authName:'数据导入',
                 path:'recover',
            
                 rights:['view','edit','add','delete']
             },
             {
                 id:53,
                 authName:'恢复默认',
                 path:'default',
                   
                 rights:['view','edit','add','delete']
             }
         ]
       }
    ],
    
  经理:[
    {
        id:1,
        authName:'物流管理',
        children:[{
            id:11,
            authName:'入库查看',
            path:'totalCheck',
            rights:['view']
        },
        {
            id:12,
            authName:'出库查看',
            path:'outputCheck',
         
            rights:['view']
        }
    
    ]
    },
     {
        id:2,
        authName:'货物管理',
        children:[{
            id:21,
            authName:'查看',
            path:'check',
          
            rights:['view']
        }]
    },
    {
        id:3,
        authName:'仓库管理',
        children:[{
            id:31,
            authName:'盘查查看',
            path:'chakan',
            rights:['view']
        }]
    },
    {
        id:4,
        authName:'员工管理',
        children:[{
            id:41,
            authName:'处理',
            path:'handle2',
            rights:['view','edit','add','delete']
        }]
    }
  ],

入库员:[
    {
        id:1,
        authName:'物流管理',
        children:[
            {
                id: 11,
                authName:'入库员',
                path:'theFirstInput',
               
                rights:['view','edit','add','delete']
            },
           
        ]
    }
],
入库核验员:[
    {
        id:1,
        authName:'物流管理',
 
      
        children:[
            {
                id: 11,
                authName:'入库核验员',
                path:'outputCheck',
             
                rights:['view','edit','add','delete']
            }
        ]
    }
],
货物管理员:[
    {
        id:1,
        authName:'货物管理',
        children:[
            {
                id:11,
                authName:'处理',
                path:'handle2',
               
                rights:['view','edit','add','delete']
                
            }
        ]
    }
],
仓库管理员:[
    {
        id:1,
        authName:'仓库管理',
     
       
        children:[
            {
                id:11,
                authName:'仓库肉类',
                path:'meat',
                show: true,
                rights:['view','edit','add','delete']
            },
            {
                id:12,
                authName:'仓库果蔬类',
                path:'fruit',
                rights:['view','edit','add','delete']
            },
            {
                id:13,
                authName:'仓库加工类',
                path:'process',
              
                rights:['view','edit','add','delete']
            },
            {
                id:14,
                authName:'仓库蛋类',
                path:'egg',
              
                rights:['view','edit','add','delete']
            }

        ]
    }
],
盘查员:[
    {
        id:1,
        authName:'仓库管理',
        children:[
            {
                id:11,
                authName:'盘查记录',
                path:'chuli',
                rights:['view','edit','add','delete']
            }
        ]
    }
],
技术管理员:[
    {
        id:1,
        authName:'技术管理',
    
       
        children:[
            {
                id:11,
                authName:'数据导出',
                path:'backup',
               
                rights:['view','edit','add','delete']
            },
            {
                id:12,
                authName:'数据导入',
                path:'recover',
           
                rights:['view','edit','add','delete']
            },
            {
                id:13,
                authName:'恢复默认',
                path:'default',
                  
                rights:['view','edit','add','delete']
            }
        ]
    }
],
出库员:[
    {
        id:1,
        authName:'物流管理',
        children:[{
            id:11,
            authName:'出库员',
            path:'output',
          
            rights:['view','edit','add','delete']
            
        }]
    },
],
出库核验员:[
    {
        id:1,
        authName:'物流管理',

     
        children:[{
            id:11,
            authName:'出库核验',
            path:'outputCheck',
           
            rights:['view','edit','add','delete']
        }]
    }
]
    
}

// 用户登录
Mock.mock('/login', 'post', option => {
  const { username, password } = JSON.parse(option.body)
  const user = users.find(item => {
    return item.username === username && item.password === password
  })
  return user
})

// 用户权限信息
Mock.mock('/roles', 'post', option => {
  return roles[option.body]
})


